package com.wframe.project.former.dataservices.sysman;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.hibernate.HibernateException;

import com.frame.database.BaseDao;
import com.frame.database.JBaseService;
import com.frame.database.JServiceFactory;
import com.frame.database.JdataBean;
import com.wframe.project.former.dataservices.sysman.dao.SysproDao;

public class SysmanService extends JBaseService<SysproDao>{

	public static SysmanService getIntance(){
        return JServiceFactory.createJServiceProxy(SysmanService.class);
    }
	
	public void saveSysproVal(JdataBean bean) throws Exception{
		Object[] keys=bean.getDataMap().keySet().toArray();
		for(Object key:keys){
			getDao().saveSysproVal(key.toString(), bean.getString(key.toString()));
		}
	}
	public JdataBean getSyspro() throws Exception{
		List<JdataBean> list=getDao().querySyspro();
		JdataBean bean=new JdataBean();
		for(JdataBean b:list)
			bean.put(b.getString("code"), b.getString("val"));
		return bean;
	}
	public List<JdataBean> queryAreatrad() throws Exception{
		List<JdataBean> list= getDao().queryAreatrad();
		for(JdataBean d:list){
			d.put("text", d.getDefault("province", "").toString()+d.getDefault("city", "").toString()+d.getDefault("area", "").toString());
		}
		return list;
	}
	public void saveAreatrad(JdataBean bean) throws Exception{
		getDao().saveAreatrad(bean);
	}
	public void delAreatrad(String id) throws HibernateException, Exception{
		getDao().delAreatrad(id);
	}
	public JdataBean getAreatrad(String id) throws Exception{
		return getDao().getAreatrad(id);
	}
}
